﻿using System.Windows;
using System.Windows.Controls;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition;
using System.Collections.ObjectModel;

namespace SilverlightApplication5
{
    public partial class MainPage : UserControl
    {
        [ImportMany]
        public ObservableCollection<IMessage> Messages { get; set; }

        public MainPage()
        {

            var catalog = new PackageCatalog();
            catalog.AddPackage(Package.Current);
            var container = new CompositionContainer(catalog);
            container.ComposeParts(this);

            InitializeComponent();
            LayoutRoot.DataContext = Messages;
        }

    }

    [InheritedExport]
    public interface IMessage { }

    public class SimpleHello : IMessage
    {
        public override string ToString()
        {
            return "Hello World! -- 5";
        }
    }

    public class SimpleHola : IMessage
    {
        public override string ToString()
        {
            return "Hola --5 ";
        }
    }
}
